package czk.concrent.threadstatus;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/5/6 22:27
 */
// 守护线程
public class DemonThread {
    public static void main(String[] args) throws InterruptedException {
        Thread t1=new Thread(()->{
            while (true){
                System.out.println("守护线程运行中");
            }
        },"t1");
        // 设置为守护线程，当主线程运行结束，不管其有没有结束都会停止线程
        // long t=System.currentTimeMillis();
        t1.setDaemon(true);
        t1.start();
        Thread.sleep(1*100);
        System.out.println("主线程运行结束");
    }
}
